/**
 * Copyright Statement:
 * This software and related documentation (ESWIN SOFTWARE) are protected under relevant copyright laws.
 * The information contained herein is confidential and proprietary to
 * Beijing ESWIN Computing Technology Co., Ltd.(ESWIN)and/or its licensors.
 * Without the prior written permission of ESWIN and/or its licensors, any reproduction, modification,
 * use or disclosure Software, and information contained herein, in whole or in part, shall be strictly prohibited.
 *
 * Copyright ©[2023] [Beijing ESWIN Computing Technology Co., Ltd.]. All rights reserved.
 *
 * RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES THAT THE SOFTWARE
 * AND ITS DOCUMENTATIONS (ESWIN SOFTWARE) RECEIVED FROM ESWIN AND / OR ITS REPRESENTATIVES
 * ARE PROVIDED TO RECEIVER ON AN "AS-IS" BASIS ONLY. ESWIN EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE OR NON INFRINGEMENT.
 * NEITHER DOES ESWIN PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE SOFTWARE OF ANY THIRD PARTY
 * WHICH MAY BE USED BY,INCORPORATED IN, OR SUPPLIED WITH THE ESWIN SOFTWARE,
 * AND RECEIVER AGREES TO LOOK ONLY TO SUCH THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO.
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 * IN NO EVENT SHALL ESWIN BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 *
 * @file pin_config.c
 * @author abu (abu@eswincomputing.com)
 * @date 2024-01-24
 *
 */

#include "pin_config.h"

/**
 * @brief User configuration structure
 * 合并配置说明：
 * 索引0-3:   UART1引脚 (蓝牙HC05)
 * 索引4-7:   SPI0引脚 (SD卡)
 * 索引8-12:  Arduino传感器引脚 (LED, PWM, 蜂鸣器, UART2)
 * 索引13:    DHT11温湿度传感器引脚 (PORTB11)
 */
pin_settings_config_t g_stPinmuxConfigArr[NUM_OF_CONFIGURED_PINS] = {
    // UART1引脚配置 (蓝牙HC05) - 索引0-3
    {
        //UART1_RX function, 100pin package, 25pin
        .base        = PORTA,
        .pinPortIdx  = 26U,
        .pullConfig  = PORT_INTERNAL_PULL_UP_ENABLED,
        .driveSelect = PORT_STR2_DRIVE_STRENGTH,
        .mux         = PORT_MUX_ALT3,
        .isGpio      = false,
    },
    {
        //UART1_TX function, 100pin package, 24pin
        .base        = PORTA,
        .pinPortIdx  = 25U,
        .pullConfig  = PORT_INTERNAL_PULL_NOT_ENABLED,
        .driveSelect = PORT_STR2_DRIVE_STRENGTH,
        .mux         = PORT_MUX_ALT3,
        .isGpio      = false,
    },
    {
        //UART1_RTS function, 100pin package, 84pin
        .base        = PORTD,
        .pinPortIdx  = 10U,
        .pullConfig  = PORT_INTERNAL_PULL_NOT_ENABLED,
        .driveSelect = PORT_STR2_DRIVE_STRENGTH,
        .mux         = PORT_MUX_ALT6,
        .isGpio      = false,
    },
    {
        //UART1_CTS function, 100pin package, 85pin
        .base        = PORTD,
        .pinPortIdx  = 11U,
        .pullConfig  = PORT_INTERNAL_PULL_NOT_ENABLED,
        .driveSelect = PORT_STR2_DRIVE_STRENGTH,
        .mux         = PORT_MUX_ALT6,
        .isGpio      = false,
    },
    
    // SPI0引脚配置 (SD卡) - 索引4-7
    {
        //SPI0_PCS0 function, 100pin package, 54pin
        .base        = PORTC,
        .pinPortIdx  = 1U,
        .pullConfig  = PORT_INTERNAL_PULL_NOT_ENABLED,
        .driveSelect = PORT_STR2_DRIVE_STRENGTH,
        .mux         = PORT_MUX_ALT3,
        .isGpio      = false,
    },
    {
        //SPI0_SCK function, 100pin package, 48pin
        .base        = PORTB,
        .pinPortIdx  = 23U,
        .pullConfig  = PORT_INTERNAL_PULL_NOT_ENABLED,
        .driveSelect = PORT_STR2_DRIVE_STRENGTH,
        .mux         = PORT_MUX_ALT3,
        .isGpio      = false,
    },
    {
        //SPI0_SIN function, 100pin package, 47pin
        .base        = PORTB,
        .pinPortIdx  = 20U,
        .pullConfig  = PORT_INTERNAL_PULL_NOT_ENABLED,
        .driveSelect = PORT_STR2_DRIVE_STRENGTH,
        .mux         = PORT_MUX_ALT3,
        .isGpio      = false,
    },
    {
        //SPI0_SOUT function, 100pin package, 53pin
        .base        = PORTC,
        .pinPortIdx  = 0U,
        .pullConfig  = PORT_INTERNAL_PULL_NOT_ENABLED,
        .driveSelect = PORT_STR2_DRIVE_STRENGTH,
        .mux         = PORT_MUX_ALT3,
        .isGpio      = false,
    },
    
    // Arduino传感器引脚配置 - 索引8-12
    {
        //PORTC4 function (LED), 100pin package, 56pin
        .base           = PORTC,
        .pinPortIdx     = 4U,
        .pullConfig     = PORT_INTERNAL_PULL_NOT_ENABLED,
        .driveSelect    = PORT_STR2_DRIVE_STRENGTH,
        .mux            = PORT_MUX_ALT1,
        .isGpio         = true,
        .direction      = GPIO_OUTPUT_DIRECTION,
        .initValue      = 0,
        .intConfig      = PORT_INT_LOW_LEVEL,
        .clearIntFlag   = true,
        .debounceEnable = false,
    },
    {
        //PWM1 function, 100pin package, 42pin
        .base        = PORTB,
        .pinPortIdx  = 12U,
        .pullConfig  = PORT_INTERNAL_PULL_NOT_ENABLED,
        .driveSelect = PORT_STR1_DRIVE_STRENGTH,
        .mux         = PORT_MUX_ALT2,
        .isGpio      = false,
    },
    {
        //PORTB30 function (蜂鸣器), 100pin package, 52pin
        .base           = PORTB,
        .pinPortIdx     = 30U,
        .pullConfig     = PORT_INTERNAL_PULL_NOT_ENABLED,
        .driveSelect    = PORT_STR2_DRIVE_STRENGTH,
        .mux            = PORT_MUX_ALT1,
        .isGpio         = true,
        .direction      = GPIO_OUTPUT_DIRECTION,
        .initValue      = 0,
        .intConfig      = PORT_INT_LOW_LEVEL,
        .clearIntFlag   = true,
        .debounceEnable = false,
    },
    {
        //UART2_RX function, 100pin package, 20pin
        .base        = PORTA,
        .pinPortIdx  = 18U,
        .pullConfig  = PORT_INTERNAL_PULL_UP_ENABLED,
        .driveSelect = PORT_STR2_DRIVE_STRENGTH,
        .mux         = PORT_MUX_ALT3,
        .isGpio      = false,
    },
    {
        //UART2_TX function, 100pin package, 19pin
        .base        = PORTA,
        .pinPortIdx  = 16U,
        .pullConfig  = PORT_INTERNAL_PULL_NOT_ENABLED,
        .driveSelect = PORT_STR2_DRIVE_STRENGTH,
        .mux         = PORT_MUX_ALT3,
        .isGpio      = false,
    },
    
    // DHT11温湿度传感器引脚配置 - 索引13
    {
        //PORTB11 function (DHT11), 100pin package, 51pin
        .base           = PORTB,
        .pinPortIdx     = 11U,
        .pullConfig     = PORT_INTERNAL_PULL_NOT_ENABLED,
        .driveSelect    = PORT_STR2_DRIVE_STRENGTH,
        .mux            = PORT_MUX_ALT1,
        .isGpio         = true,
        .direction      = GPIO_OUTPUT_DIRECTION,
        .initValue      = 1,
        .intConfig      = PORT_INT_LOW_LEVEL,
        .clearIntFlag   = true,
        .debounceEnable = false,
    },
};
